//
//  mFilterResult.swift
//  ShopIOS
//
//  Created by Apple on 2019/8/7.
//  Copyright © 2019 Apple. All rights reserved.
//

import Foundation
import SwiftyJSON

struct mFilterResult {
    var Success: String?
    var Category = [mFilterCategory]()
    var Brand = [mFilterBrand]()
    var Attrs = [mFilterAttrs]()
    
    init(json: JSON) {
        Success = json["Success"].stringValue
        Category = json["Category"].arrayValue.compactMap({ mFilterCategory(json: $0)})
        Brand = json["Brand"].arrayValue.compactMap({ mFilterBrand(json: $0)})
        Attrs = json["Attrs"].arrayValue.compactMap({ mFilterAttrs(json: $0)})
    }
}

class mFilterCategory {
    var Id: Int = 0
    var SubCategory = [mFilterCategory]()
    var Name: String?
    var isSelected:Bool = false          /* 记录相应row是否选中（自定义）*/
    
    init(json: JSON) {
        Id = json["Id"].intValue
        SubCategory = json["SubCategory"].arrayValue.compactMap({ mFilterCategory(json: $0)})
        Name = json["Name"].stringValue
    }
}

class mFilterBrand {
    var Id: Int = 0
    var Logo: String?
    var Name: String?
    var isSelected:Bool = false          /* 记录相应row是否选中（自定义）*/
    
    init(json: JSON) {
        Id = json["Id"].intValue
        Logo = json["Logo"].stringValue
        Name = json["Name"].stringValue
    }
}

class mFilterAttrValues {
    var Name: String?
    var Id: Int = 0
    var isSelected:Bool = false          /* 记录相应row是否选中（自定义）*/
    
    init(json: JSON) {
        Name = json["Name"].stringValue
        Id = json["Id"].intValue
    }
}

class mFilterAttrs {
    var AttrId: Int = 0
    var Name: String?
    var AttrValues = [mFilterAttrValues]()
    
    init(json: JSON) {
        AttrId = json["AttrId"].intValue
        Name = json["Name"].stringValue
        AttrValues = json["AttrValues"].arrayValue.compactMap({ mFilterAttrValues(json: $0)})
    }
}
